﻿using FoodModel;
using J.FoodManageGet.Application.Command.TasteCommand;
using J.FoodRepository.InterFace;
using MediatR;

namespace J.FoodManageGet.Application.CommandHandler.TasteCommandHandler
{
    public class TasteShowCommandHandler : IRequestHandler<TasteShowCommand, List<TasteModel>>
    {
        private readonly ITasteRepository _tasteRepository;

        public TasteShowCommandHandler(ITasteRepository tasteRepository)
        {
            _tasteRepository = tasteRepository;
        }
        public async Task<List<TasteModel>> Handle(TasteShowCommand request, CancellationToken cancellationToken)
        {
            var list = await _tasteRepository.GetAllAsync();
            var list1 = list.OrderByDescending(x => x.TasteId);
            return list1.ToList();
        }
    }
}
